package test;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPubSub;

public class Subscriber extends JedisPubSub {
    private String[] channels;

    public Subscriber(String[] channels) {
        this.channels = channels;
    }

    @Override
    public void onMessage(String channel, String message) {
        System.out.println("Received message from channel: " + channel + " - Message: " + message);
    }

    public void subscribe() {
        try (Jedis jedis = new Jedis("10.255.48.177", 31219)) {
        	jedis.auth("Trtjk2024");
            jedis.subscribe(this, channels);
        }
    }
}
